package entity;

import java.util.HashMap;
import java.util.Map;

/**
 * describe 数据库类型映色类
 * author wencong 2022/3/3
 */
public class TypeEntity {

    // 获取项目对象
    public static Map<String, String> getType(String typeName) {
        return switch (typeName) {
            case "net" -> netTypeMap;
            case "java" -> javaTypeMap;
            default -> new HashMap<>();
        };
    }

    // mysql对应java数据类型集合
    public static Map<String, String> javaTypeMap = new HashMap<>();

    // mysql对应net数据类型集合
    public static Map<String, String> netTypeMap = new HashMap<>(){{
        put("tinyint", "int?");
        put("smallint", "int?");
        put("mediumint", "int?");
        put("int", "int?");
        put("integer", "int?");
        put("bigint", "long?");
        put("float", "float?");
        put("double", "double?");
        put("decimal", "double?");
        put("date", "DateTime");
        put("time", "DateTime");
        put("year", "DateTime");
        put("datetime", "DateTime");
        put("timestamp", "DateTime");
        put("char", "string");
        put("varchar", "string");
        put("tinyblob", "string");
        put("tinytext", "string");
        put("blob", "string");
        put("text", "string");
        put("mediumblob", "string");
        put("mediumtext", "string");
        put("longblob", "string");
        put("longtext", "string");
    }};

    public TypeEntity() {
    }
}
